﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<style type="text/css">
    .form .formValue input.form-control {
        height: 32px;
        line-height: 32px;
        padding: 0px;
        resize: none;
        border-radius: 0px;
        box-shadow: none;
        text-indent: 5px
    }
    .zdyPanel {
        background-color: #fff;
        border-top: 1px solid #ddd;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        margin: 0px;
        float: left;
        width: 100%;
    }
    .zdyBar {
        padding: 0px;
        margin: 0px;
        margin-top: 3px;
    }
    .zdyGirdPanel {
        width: 100%;
        margin: 0px;
        padding: 0px;
        float: left;
    }
    .zdyUL {
        list-style-type: none;
        margin: 5px 0px 0px -3px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 24px;
            line-height: 22px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }
</style>
<script>
    $(function () {
        gridList();
    });      
    function gridList() {
        var type = $.request("type");
        var $gridList = $("#gridList");
        var F_StartTime = $("#F_StartTime").val();
        var F_EndTime = $("#F_EndTime").val();
        var queryJson = {
            F_StartTime: F_StartTime,
            F_EndTime: F_EndTime,
            F_Type: type
        };
        $gridList.dataGrid({
            url: "/OrderFlowManage/ClientOrder/GetSaleReportGridData",
            postData: { queryJson: JSON.stringify(queryJson) },
            height: 680,
            colModel: [       
                {
                    label: '操作', name: '', align: 'left', width: 150, formatter: function (cellvalue, options, rowObject) {
                        var html = "<ul class=\"zdyUL\" style=\"white-space:nowrap;\">";
                        html += "<li><a id=\"" + rowObject["F_DemandId"] + "\" onclick=\"btn_Edit('" + rowObject["F_DemandId"] + "')\"> 日报记录</a></li>";
                        if (type == "self") {
                            html += "<li><a id=\"" + rowObject["F_OrderId"] + "\" onclick=\"btn_Add('" + rowObject["F_OrderId"] + "')\"> 新建日报</a></li>";
                        } else if (type == "all") {
                            html += "<li><a id=\"" + rowObject["F_Id"] + "\" onclick=\"btn_read('" + rowObject["F_Id"] + "')\"> 查看日报</a></li>";
                        }                        
                        html += "</ul>";
                        return html;
                    }
                },
                { label: '活动主题', width: 120, name: 'F_ActivityTheme' },
                {
                    label: '跟踪记录', name: 'reportState', width: 60, align: 'center', sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var html = '';
                        if (cellvalue == "1") {
                            html = '<span class="glyphicon glyphicon-star text-danger"></span>&nbsp;&nbsp;';
                        }
                        return html;
                    }
                },
                {
                    label: '需求阶段', width: 60, name: 'F_OrderState', formatter: function (cellvalue) {
                        if (cellvalue == "1") {
                            return '<span style=\'color:#fc8675;\'>场地推荐</span>';
                        }
                        else if (cellvalue == "2") {
                            return '<span style=\'color:#fc8675;\'>带看场地</span>';
                        }
                        else if (cellvalue == "3") {
                            return '<span style=\'color:#fc8675;\'>意向场地</span>';
                        }
                        else if (cellvalue == "4") {
                            return '<span style=\'color:#fc8675;\'>价格协商</span>';
                        }
                        else if (cellvalue == "5") {
                            return '<span style=\'color:#fc8675;\'>场地预定</span>';
                        }
                        else if (cellvalue == "6") {
                            return '<span style=\'color:#fc8675;\'>用印申请</span>';
                        }
                        else if (cellvalue == "7") {
                            return '<span style=\'color:#fc8675;\'>合同审核</span>';
                        } else if (cellvalue == "8") {
                            return '<span style=\'color:#fc8675;\'>订单完成</span>';
                        }
                    }
                }, 
                { label: '开始时间', width: 70, name: 'F_ActivityStartDate' },               
                { label: '预算', name: 'F_DemandCash', width: 70, align: 'left' },
                { label: '跟进时间', name: 'F_CreatorTime', width: 120, align: 'left' },
                { label: '销售人员', name: 'F_RealName', width: 80, align: 'left' },        
                {
                    label: '日报标题', name: 'F_ReportTitle', width: 150, align: 'left'
                },                               
                { label: '日报内容', name: 'F_Context', width: 600, align: 'left' },                                
                { label: '', name: 'F_Id', hidden: true },          
                { label: '', name: 'F_DemandId', hidden: true },  
                { label: '', name: 'F_OrderId', hidden: true },    
            ],
            pager: "#gridPager",
            viewrecords: true,
            multiselect: false,
            sortname: 'F_Id',
            rowNum: 20,
            rowList: [20, 40, 60],
            ondblClickRow: function (rowid, iRow, iCol, e) {    
                if (type == "self") {
                    detail();
                } else if (type == "all") {
                    var rowobj = $("#gridList").jqGridRowValue();
                    $.modalOpen({
                        id: "editDemandForm2",
                        title: "需求单详细",
                        url: "/ClientManager/ClientInfos/EditDemandForm?DemandId=" + rowobj.F_DemandId + "&type=2",
                        width: "1200px",
                        height: "650px",
                        callBack: function (iframeId) {
                            top.frames[iframeId].submitForm();
                        },
                        btn: null
                    });
                }
            },
            loadComplete: function (data) {

            }
        });
    }

    function btn_Edit(F_DemandId) {
        var type = $.request("type");
        $.modalOpen({
            id: "reportHistoryList",
            title: "日报历史记录",
            url: "/OrderFlowManage/ClientOrder/OrderReportList?F_DemandId=" + F_DemandId + "&type=" + type +"",
            width: "800px",
            height: "600px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            },
            btn: null
        });
    }

    function btn_Add(orderId) {
        $.modalOpen({
            id: "salesreport",
            title: "销售日报",
            url: "/OrderFlowManage/ClientOrder/OrderTrackingReport?orderId=" + orderId + "&F_OrderStep=1",
            width: "800px",
            height: "600px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

    function btn_read(F_Id) {
        $.modalOpen({
            id: "editsalesreport",
            title: "销售日报",
            url: "/OrderFlowManage/ClientOrder/OrderTrackingReport?orderId=" + $.request('orderid') + "&F_OrderStep=1&F_Id=" + F_Id + "",
            width: "800px",
            height: "600px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            },
            btn: null
        });
    }

    function detail() {
        var rowobj = $("#gridList").jqGridRowValue();
        $.modalOpen({
            id: "editsalesreport",
            title: "销售日报",
            url: "/OrderFlowManage/ClientOrder/OrderTrackingReport?orderId=" + $.request('orderid') + "&F_OrderStep=1&F_Id=" + rowobj.F_Id +"",
            width: "800px",
            height: "600px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();                
            }
        });
    }

    function btn_onSearch() {
        var $gridList = $("#gridList");
        var F_StartTime = $("#F_StartTime").val();
        var F_EndTime = $("#F_EndTime").val();
        var type = $.request("type");
        var queryJson = {
            F_StartTime: F_StartTime,
            F_EndTime: F_EndTime,
            F_Type: type
        };
        $gridList.jqGrid('setGridParam', {
            postData: { queryJson: JSON.stringify(queryJson) },
        }).trigger('reloadGrid');
    }
</script>
<div class="zdyPanel">
    <div class="zdyBar" style="float:left;white-space:nowrap;width:50%;">
        <div class="search">
            <table class="form" style="width:100%;">                
                <tr>                   
                    <td class="formValue">
                        <input type="text" id="F_StartTime" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="请输入开始时间" />
                    </td>
                    <td class="formValue">
                        <input type="text" id="F_EndTime" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="请输入截至时间" />
                    </td>
                    <td class="formValue">                        
                    </td>
                    <td class="formValue"></td>
                </tr>                
            </table>
        </div>
    </div>
    <div class="zdyBar" style="float:right;white-space:nowrap;width:50%;padding-top:5px;">
        <div style="float:right;margin-right:5px;">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>
            <div class="btn-group">
                <a class="btn btn-primary" onclick="btn_onSearch()" id="btn_search">查询</a>
            </div>          
        </div>
    </div>
</div>
<div class="zdyGirdPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

